/*
 * srm 212 div 2 prob 3
 */

import java.util.*;
import java.util.regex.*;
import java.text.*;
import java.math.*;


public class LargestCircle
{
    int M, N;
    boolean[][] matrix;
    
    boolean checkRadius (int cx, int cy, int r) {
	if (r == 0)
	    return true;
	if (cx < r || cx + r > N)
	    return false;
	if (cy < r || cy + r > M)
	    return false;
	int xmin = cx - r, xmax = cx + r - 1, ymin = cy - r, ymax = cy + r - 1;
	
	for (int x = xmin; x <= xmax; ++x)
	    for (int y = ymin; y <= ymax; ++y) {
		int[] d = new int[4];
		for (int i = 0; i < 2; ++i)
		    for (int j = 0; j < 2; ++j)
			d[2*i+j] = (x + i - cx) * (x + i - cx) + (y + j - cy) * (y + j - cy);
		
		int min = d[0], max = d[0];
		for (int i = 1; i < 4; ++i) {
		    min = Math.min (min, d[i]);
		    max = Math.max (max, d[i]);
		}
		if (min >= r * r || max <= r * r)
		    continue;
		if (!matrix[y][x])
		    return false;
	    }
	return true;
    }
    
    int checkMaxRadius (int cx, int cy) {
	int r = Math.min (cx, N - cx);
	r = Math.min (r, cy);
	r = Math.min (r, M  - cy);
	for (int ans = r; ans >= 0; --ans) 
	    if (checkRadius (cx, cy, ans))
		return ans;
	
	return 0;
    }

    public int radius(String[] grid)
    {
	M = grid.length;
	N = grid[0].length ();
	matrix = new boolean[M][N];
	for (int i = 0; i < M; ++i)
	    for (int j = 0; j < N; ++j)
		if (grid[i].charAt (j) == '.') 
		    matrix[i][j] = true;
	int ans = 0;
	for (int x = 0; x < N; ++x)
	    for (int y = 0; y < M; ++y) 
		ans = Math.max (ans, checkMaxRadius (x, y));
	return ans;
    }
    
    <%:testing-code%>
}
//Powered by KawigiEdit 2.1.4 (beta) modified by pivanof!